//
//  NSObject+ZMQuickAlert.m
//  YYFMMall
//
//  Created by chenzm on 2019/8/23.
//  Copyright © 2019 YuYou1. All rights reserved.
//

#import "NSObject+ZMQuickAlert.h"
#import "UIAlertView+Fast.h"//系统弹出框快捷方式1
#import "UIActionSheet+Fast.h"//系统弹出框快捷方式2

@implementation NSObject (ZMQuickAlert)


#pragma -mark 提示框1
+(void)alertViewWithTitle:(NSString*)title
              contentText:(NSString*)contStr
          leftButtonTitle:(NSString*)leftstr//nil--0
         rightButtonTitle:(NSString*)rightstr//@"sure"--1
                   finish:(void (^)(NSInteger index))block
{
    
    
    UIAlertView *alert;
    
    alert = [[UIAlertView alloc]initWithTitle:title
                                      message:contStr
                                     delegate:nil
                            cancelButtonTitle:leftstr
                            otherButtonTitles:rightstr, nil];
    
    [alert showAlertViewWithCompleteBlock:^(NSInteger buttonIndex) {
        
        if (block) {
            block(buttonIndex);
        }
    }];
}
#pragma -mark 提示框2
+(void)sheetWithTitle:(NSString*)title
              oneText:(NSString*)oneText//0
              twoText:(NSString*)twoText//1
               finish:(void (^)(NSInteger index))block{
    UIActionSheet *sheet;
    sheet=[[UIActionSheet alloc]initWithTitle:title
                                     delegate:nil
                            cancelButtonTitle:@"取消"
                       destructiveButtonTitle:nil
                            otherButtonTitles:oneText,twoText, nil];
    [sheet showActionSheetWithCompleteBlock:^(NSInteger buttonIndex) {
        
        if (block) {
            block(buttonIndex);
        }
    }];
}
#pragma -mark 提示框3
+(void)sheetWithTitle:(NSString*)title
    otherButtonTitles:(NSArray *)otherButtonTitles
               finish:(void (^)(NSInteger index))block
{
    UIActionSheet *sheet;
    sheet=[[UIActionSheet alloc]initWithTitle:title
                                     delegate:nil
                            cancelButtonTitle:@"取消"
                       destructiveButtonTitle:nil
                            otherButtonTitles:nil];
    for (int i = 0; i < otherButtonTitles.count; i++) {
        [sheet addButtonWithTitle:otherButtonTitles[i]];
    }
    [sheet showActionSheetWithCompleteBlock:^(NSInteger buttonIndex) {
        
        if (block) {
            block(buttonIndex);
        }
    }];
}



@end
